package com.dabay.web.util;

import java.io.Serializable;


public class ResultSupport<T> implements Serializable{
	private static final long serialVersionUID = 1L;
	
	private boolean success;    //成功失败
	private Integer resultCode; //返回码
	private String message;     //返回消息
	private T model;            //返回数据
	private Integer totalCount; //符合条件的记录总数
	private Integer totalPage;  //符合条件的记录页数
	
	public ResultSupport(){};
	
	/**
	 * @param success 是否成功
	 * @param resultCode 返回码
	 */
	public ResultSupport(boolean success, Integer resultCode) {
		this.success = success;
		this.resultCode = resultCode;
	}
	/**
	 * 设置用于翻页的记录条数信息
	 * @param queryBase
	 */
	public void setPageProperty(QueryBase queryBase) {
		this.totalCount = queryBase.getTotalItem();
		this.totalPage = queryBase.getTotalPage();
	}
	
	/**
	 * @param message 错误消息
	 */
	public ResultSupport(String message) {
		this.success = false;
		this.message = message;
	}
	
	public boolean isSuccess() {
		return success;
	}
	public void setSuccess(boolean success) {
		this.success = success;
	}
	public Integer getResultCode() {
		return resultCode;
	}
	public void setResultCode(Integer resultCode) {
		this.resultCode = resultCode;
	}
	public String getMessage() {
		return message;
	}
	public void setMessage(String message) {
		this.message = message;
	}
	public T getModel() {
		return model;
	}
	public void setModel(T model) {
		this.model = model;
	}
	public Integer getTotalCount() {
		return totalCount;
	}
	public void setTotalCount(Integer totalCount) {
		this.totalCount = totalCount;
	}
	public Integer getTotalPage() {
		return totalPage;
	}
	public void setTotalPage(Integer totalPage) {
		this.totalPage = totalPage;
	}
	
}

